<template>
        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                    <div class="panel-heading">文章首页列表</div>

                    <div class="panel-body">

                        <div v-for="post in posts" :key="post.id" class="bs-callout bs-callout-danger">
                            <router-link :to="{ name:'posts',params:{id:post.id} }"><h4>{{post.title}}</h4></router-link>
                            <p>{{post.body}}</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
</template>

<script>
    export default {
        mounted(){
            axios.get('http://mg.com/posts').then((response) => {
//                console.log(response.data)
                this.posts=response.data
        })
        },
        data(){
            return {
                posts:[]
            }
        }
    }
</script>
